package com.zzyweb.rentalcarsys.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * @author zhiyi
 * @date 9/29/25
 **/
@Component
public class RedisUtil {
    @Autowired
    RedisTemplate<String, String> redisTemplate;
    public void set(String key, String value) {
        redisTemplate.opsForValue().set(key,value,3, TimeUnit.MINUTES);
    }
    public String get(String key) {
        return redisTemplate.opsForValue().get(key);
    }
    public void set(String key, String value,Long timeout,TimeUnit timeUnit) {
        redisTemplate.opsForValue().set(key,value,timeout,timeUnit);
    }
    public void banEmail(String to) {
        redisTemplate.opsForValue().set(to,"banned",24, TimeUnit.HOURS);
    }
}
